package cz.mpelant.msoe.mealchecker.downloader;

import java.io.OutputStream;

import org.apache.http.client.methods.HttpUriRequest;

public class DownloadRequest {

    private static final int DEFAULT_RETRIES_COUNT = 5;

	protected HttpUriRequest httpRequest;
	// output stream where returned content will be written
	// e.g. FileOutputStream or ByteArrayOutputStream
	private OutputStream os;
	// identifies this request when result is being passed to the listener
	private String id;
	// number of retries to establish connection until an error is returned
	private int retries;

	public DownloadRequest(HttpUriRequest httpRequest, OutputStream os, String id, int retries) {
		super();
		this.httpRequest = httpRequest;
		this.os = os;
		this.id = id;
		this.retries = retries;
	}

	public DownloadRequest(HttpUriRequest httpRequest, OutputStream os, String id) {
	    this(httpRequest, os, id, DEFAULT_RETRIES_COUNT);
	}
	
	public HttpUriRequest getHttpRequest() {
		return httpRequest;
	}

	public void setHttpRequest(HttpUriRequest httpRequest) {
		this.httpRequest = httpRequest;
	}

	public OutputStream getOs() {
		return os;
	}

	public void setOs(OutputStream os) {
		this.os = os;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public int getRetries() {
		return retries;
	}

	public void setRetries(int retries) {
		this.retries = retries;
	}

	@Override
	public boolean equals(Object o) {
		if (o instanceof DownloadRequest)
			return ((DownloadRequest) o).id.equals(id);
		return false;
	}

}
